<?php
declare (strict_types = 1);
namespace app\api\logic;
use app\admin\model\Shop;
use app\admin\model\ShopSetting as ss;
use app\admin\model\Banner;
use app\admin\model\mk\Seckill;
class ShopLogic
{
	function info($args = []){
		  $arr = Shop::where("sid",$args['shop_id'])->find();
		  return $arr;
	}
	//店铺文字类型简介
	function about($args = []){
		 $type = $args['type'] ?? '';
		 $mode = $args['mode'] ?? '';
		 switch ($mode) {
		 	case 'miaosha':
		 		$res = Seckill::where(['id'=>$args['id'],'shop_id'=>$args['shop_id']])->find();
		 		$res['settings'] = $res['content'];
		 		break;
		 	
		 	default:
		 		$res = ss::where(['type'=>'about','shop_id'=>$args['shop_id'],'name'=>$type])->find();
		 		break;
		 }
		 
		 return $res;
	}
	//店铺轮播图
	function banner($args = []){
	     $res = Banner::where("shop_id",$args['shop_id'])->order("weigh desc")->select();
	     $bt = $args['bt'] ?? 0;
	     switch ($bt) {
	     	case '1':
	     		foreach($res as &$v){
	     			  $data[] = "http://yunlai_shop.com".$v['pic'];
	     		}
	 			return $data;  
	     		break;
	     	
	     	default:
	     		return $res;
	     		break;
	     }
	}
}